package com.change.study.mongodb.apps;

import java.util.List;

import com.change.study.mongodb.domain.Back;
import com.change.study.mongodb.domain.MaopaoObject;
import com.change.study.mongodb.domain.MaopaoObjectBack;
import com.change.study.mongodb.service.MaoPaoRepository;
import com.change.study.mongodb.service.MaopaoService;

public class MaopaoServiceApps {

	public static void main(String[] args) {
		aaa();
		MaopaoService service = ObjectFactory.get()
				.getBean(MaopaoService.class);
		MaopaoObjectBack back = service.findByName("gggg", 1, 10);
		List<MaopaoObject> ms=	back.getActions();
		for (MaopaoObject maopaoObject : ms) {
			System.out.println(maopaoObject.images.size());
		}
	}

	private static void aaa() {
		MaoPaoRepository r = ObjectFactory.get()
				.getBean(MaoPaoRepository.class);
		;
		System.out.println(r.count());
		r.findAll();

		MaopaoObject postAction = new MaopaoObject();
		postAction.content = "fsfs";
		postAction.owner.name = "gggg";
		postAction.images.add("dsfsd");
		postAction.images.add("dsfsd");
		postAction.images.add("dsfsd");
		postAction.images.add("dsfsd");

		r.insert(postAction);
	}

	private static void aa() {
		MaopaoService service = ObjectFactory.get()
				.getBean(MaopaoService.class);

		MaopaoObject postAction = new MaopaoObject();
		postAction.content = "fsfs";
		Back back = service.Add(postAction);

		System.out.println(back);
	}

}
